/*
 * Created by Dev c++ 5.11
 * Author: liyih
 * Date: 2018/03/16
 */

#include <iostream>
using namespace std;
int main()
{
	int a[200], b[200];
	int n, m;
	cin>>n;
	for(int i = 0; i <n; i++){
		cin>>a[i];
	}
	cin>>m;
	for(int i = 0; i <m; i++){
		cin>>b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(a[i] == b[j]){
				cout<<a[i]<<" ";
			}
		}
	}
	return 0;
}

